home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / domácnost a kancelar / opencontacts / setup.exe / {app} / DataSet / Templates / ImportVista.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2007-08-18  |  12.1 KB  |  313 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <!--For converting a Windows Vista Contact file into Open Contacts XML which may be imported into Open Contacts
  3. Based on VistaToOCXML.xsl, ImportVista.xsl is created for bulk importing contact files of Windows Vista.
  4. ImportVista.xsl is used by Open Contacts directly.
  5. -->
  6. <xsl:stylesheet version="1.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:c="http://schemas.microsoft.com/Contact">
  8.   <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" />
  9.  
  10.   <xsl:template match="c:contact">
  11.  
  12.       <Contact>
  13.  
  14.           <xsl:attribute name="Name">
  15.             <xsl:value-of select="c:NameCollection/c:Name/c:FormattedName"/>
  16.           </xsl:attribute>
  17.  
  18.           <xsl:attribute name="Title">
  19.             <xsl:value-of select="c:NameCollection/c:Name/c:Title"/>
  20.           </xsl:attribute>
  21.  
  22.           <xsl:attribute name="Surname">
  23.             <xsl:value-of select="c:NameCollection/c:Name/c:FamilyName"/>
  24.           </xsl:attribute>
  25.  
  26.           <xsl:attribute name="GivenName">
  27.             <xsl:value-of select="c:NameCollection/c:Name/c:GivenName"/>
  28.           </xsl:attribute>
  29.  
  30.           <xsl:attribute name="MidName">
  31.             <xsl:value-of select="c:NameCollection/c:Name/c:MiddleName"/>
  32.           </xsl:attribute>
  33.  
  34.           <xsl:attribute name="IsCompany">
  35.             <xsl:text>0</xsl:text>
  36.           </xsl:attribute>
  37.  
  38.           <Notes>
  39.             <xsl:value-of select="c:Notes"/>
  40.           </Notes>
  41.  
  42.           <Sections>
  43.             <Section Name="Personal">
  44.               <Fields>
  45.                 <xsl:for-each select="c:EmailAddressCollection/c:EmailAddress">
  46.                   <Field>
  47.                     <xsl:attribute name="Name">
  48.                       <xsl:if test="c:LabelCollection/c:Label='Preferred'">
  49.                         <xsl:text>Primary </xsl:text>
  50.                       </xsl:if>
  51.                       <xsl:text>Email</xsl:text>
  52.                     </xsl:attribute>
  53.  
  54.                     <xsl:attribute name="Value">
  55.                       <xsl:value-of select="c:Address"/>
  56.                     </xsl:attribute>
  57.                   </Field>
  58.                 </xsl:for-each>
  59.  
  60.                 <xsl:for-each select="c:PhoneNumberCollection/c:PhoneNumber">
  61.  
  62.                   <xsl:if test="c:LabelCollection/c:Label='Pager'">
  63.                     <Field>
  64.                       <xsl:attribute name="Name">Pager</xsl:attribute>
  65.                       <xsl:attribute name="Value">
  66.                         <xsl:value-of select="c:Number"/>
  67.                       </xsl:attribute>
  68.                     </Field>
  69.                   </xsl:if>
  70.  
  71.                   <xsl:if test="c:LabelCollection/c:Label='Cellular'">
  72.                     <Field>
  73.                       <xsl:attribute name="Name">Mobile</xsl:attribute>
  74.                       <xsl:attribute name="Value">
  75.                         <xsl:value-of select="c:Number"/>
  76.                       </xsl:attribute>
  77.                     </Field>
  78.                   </xsl:if>
  79.  
  80.                   <xsl:if test="c:LabelCollection/c:Label='Fax'">
  81.                     <xsl:if test="c:LabelCollection/c:Label='Personal'">
  82.                       <Field>
  83.                         <xsl:attribute name="Name">Fax</xsl:attribute>
  84.                         <xsl:attribute name="Value">
  85.                           <xsl:value-of select="c:Number"/>
  86.                         </xsl:attribute>
  87.                       </Field>
  88.                     </xsl:if>
  89.                   </xsl:if>
  90.  
  91.                   <xsl:if test="c:LabelCollection/c:Label='Voice'">
  92.                     <xsl:if test="c:LabelCollection/c:Label='Personal'">
  93.                       <Field>
  94.                         <xsl:attribute name="Name">Phone</xsl:attribute>
  95.                         <xsl:attribute name="Value">
  96.                           <xsl:value-of select="c:Number"/>
  97.                         </xsl:attribute>
  98.                       </Field>
  99.                     </xsl:if>
  100.                   </xsl:if>
  101.  
  102.                 </xsl:for-each>
  103.  
  104.                 <xsl:for-each select="c:UrlCollection/c:Url">
  105.                   <xsl:if test="c:LabelCollection/c:Label='Personal'">
  106.                     <Field>
  107.                       <xsl:attribute name="Name">Web</xsl:attribute>
  108.                       <xsl:attribute name="Value">
  109.                         <xsl:value-of select="c:Value"/>
  110.                       </xsl:attribute>
  111.                     </Field>
  112.                   </xsl:if>
  113.                 </xsl:for-each>
  114.  
  115.                 <xsl:for-each select="c:DateCollection/c:Date">
  116.                   <xsl:if test="c:LabelCollection/c:Label='wab:Birthday'">
  117.                     <Field>
  118.                       <xsl:attribute name="Name">Birthday</xsl:attribute>
  119.                       <xsl:attribute name="Value">
  120.                         <xsl:value-of select="substring(c:Value, 1, 10)"/>
  121.                       </xsl:attribute>
  122.                     </Field>
  123.                   </xsl:if>
  124.  
  125.                   <xsl:if test="c:LabelCollection/c:Label='wab:Anniversary'">
  126.                     <Field>
  127.                       <xsl:attribute name="Name">Anniversary</xsl:attribute>
  128.                       <xsl:attribute name="Value">
  129.                         <xsl:value-of select="substring(c:Value, 1, 10)"/>
  130.                       </xsl:attribute>
  131.                     </Field>
  132.                   </xsl:if>
  133.                 </xsl:for-each>
  134.  
  135.                 <xsl:for-each select="c:PersonCollection/c:Person">
  136.                   <xsl:if test="c:LabelCollection/c:Label='wab:Spouse'">
  137.                     <Field>
  138.                       <xsl:attribute name="Name">Spouse</xsl:attribute>
  139.                       <xsl:attribute name="Value">
  140.                         <xsl:value-of select="c:FormattedName"/>
  141.                       </xsl:attribute>
  142.                     </Field>
  143.                   </xsl:if>
  144.  
  145.                 </xsl:for-each>
  146.  
  147.                 <xsl:for-each select="c:PhysicalAddressCollection/c:PhysicalAddress">
  148.                   <xsl:if test="c:LabelCollection/c:Label='Personal'">
  149.  
  150.                     <Field>
  151.                       <xsl:attribute name="Name">Street</xsl:attribute>
  152.                       <xsl:attribute name="Value">
  153.                         <xsl:value-of select="c:Street"/>
  154.                       </xsl:attribute>
  155.                     </Field>
  156.  
  157.                     <Field>
  158.                       <xsl:attribute name="Name">City</xsl:attribute>
  159.                       <xsl:attribute name="Value">
  160.                         <xsl:value-of select="c:Locality"/>
  161.                       </xsl:attribute>
  162.                     </Field>
  163.  
  164.                     <Field>
  165.                       <xsl:attribute name="Name">State</xsl:attribute>
  166.                       <xsl:attribute name="Value">
  167.                         <xsl:value-of select="c:Region"/>
  168.                       </xsl:attribute>
  169.                     </Field>
  170.  
  171.                     <Field>
  172.                       <xsl:attribute name="Name">Postcode</xsl:attribute>
  173.                       <xsl:attribute name="Value">
  174.                         <xsl:value-of select="c:PostalCode"/>
  175.                       </xsl:attribute>
  176.                     </Field>
  177.  
  178.                     <Field>
  179.                       <xsl:attribute name="Name">Country</xsl:attribute>
  180.                       <xsl:attribute name="Value">
  181.                         <xsl:value-of select="c:Country"/>
  182.                       </xsl:attribute>
  183.                     </Field>
  184.  
  185.                   </xsl:if>
  186.                 </xsl:for-each>
  187.  
  188.               </Fields>
  189.             </Section>
  190.  
  191.             <Section Name="Work">
  192.               <Fields>
  193.  
  194.                 <xsl:for-each select="c:PositionCollection/c:Position">
  195.                   <Field>
  196.                     <xsl:attribute name="Name">Office</xsl:attribute>
  197.                     <xsl:attribute name="Value">
  198.                       <xsl:value-of select="c:Office"/>
  199.                     </xsl:attribute>
  200.                   </Field>
  201.  
  202.                   <Field>
  203.                     <xsl:attribute name="Name">Deaprtment</xsl:attribute>
  204.                     <xsl:attribute name="Value">
  205.                       <xsl:value-of select="c:Department"/>
  206.                     </xsl:attribute>
  207.                   </Field>
  208.  
  209.                   <Field>
  210.                     <xsl:attribute name="Name">Title</xsl:attribute>
  211.                     <xsl:attribute name="Value">
  212.                       <xsl:value-of select="c:JobTitle"/>
  213.                     </xsl:attribute>
  214.                   </Field>
  215.  
  216.                   <Field>
  217.                     <xsl:attribute name="Name">Company</xsl:attribute>
  218.                     <xsl:attribute name="Value">
  219.                       <xsl:value-of select="c:Company"/>
  220.                     </xsl:attribute>
  221.                   </Field>
  222.  
  223.                 </xsl:for-each>
  224.  
  225.                 <xsl:for-each select="c:PhoneNumberCollection/c:PhoneNumber">
  226.  
  227.                   <xsl:if test="c:LabelCollection/c:Label='Fax'">
  228.                     <xsl:if test="c:LabelCollection/c:Label='Business'">
  229.                       <Field>
  230.                         <xsl:attribute name="Name">Fax</xsl:attribute>
  231.                         <xsl:attribute name="Value">
  232.                           <xsl:value-of select="c:Number"/>
  233.                         </xsl:attribute>
  234.                       </Field>
  235.                     </xsl:if>
  236.                   </xsl:if>
  237.  
  238.                   <xsl:if test="c:LabelCollection/c:Label='Voice'">
  239.                     <xsl:if test="c:LabelCollection/c:Label='Business'">
  240.                       <Field>
  241.                         <xsl:attribute name="Name">Phone</xsl:attribute>
  242.                         <xsl:attribute name="Value">
  243.                           <xsl:value-of select="c:Number"/>
  244.                         </xsl:attribute>
  245.                       </Field>
  246.                     </xsl:if>
  247.                   </xsl:if>
  248.  
  249.                 </xsl:for-each>
  250.  
  251.                 <xsl:for-each select="c:PhysicalAddressCollection/c:PhysicalAddress">
  252.                   <xsl:if test="c:LabelCollection/c:Label='Business'">
  253.  
  254.                     <Field>
  255.                       <xsl:attribute name="Name">Street</xsl:attribute>
  256.                       <xsl:attribute name="Value">
  257.                         <xsl:value-of select="c:Street"/>
  258.                       </xsl:attribute>
  259.                     </Field>
  260.  
  261.                     <Field>
  262.                       <xsl:attribute name="Name">City</xsl:attribute>
  263.                       <xsl:attribute name="Value">
  264.                         <xsl:value-of select="c:Locality"/>
  265.                       </xsl:attribute>
  266.                     </Field>
  267.  
  268.                     <Field>
  269.                       <xsl:attribute name="Name">State</xsl:attribute>
  270.                       <xsl:attribute name="Value">
  271.                         <xsl:value-of select="c:Region"/>
  272.                       </xsl:attribute>
  273.                     </Field>
  274.  
  275.                     <Field>
  276.                       <xsl:attribute name="Name">Postcode</xsl:attribute>
  277.                       <xsl:attribute name="Value">
  278.                         <xsl:value-of select="c:PostalCode"/>
  279.                       </xsl:attribute>
  280.                     </Field>
  281.  
  282.                     <Field>
  283.                       <xsl:attribute name="Name">Country</xsl:attribute>
  284.                       <xsl:attribute name="Value">
  285.                         <xsl:value-of select="c:Country"/>
  286.                       </xsl:attribute>
  287.                     </Field>
  288.  
  289.                   </xsl:if>
  290.                 </xsl:for-each>
  291.  
  292.                 <xsl:for-each select="c:UrlCollection/c:Url">
  293.                   <xsl:if test="c:LabelCollection/c:Label='Business'">
  294.  
  295.                     <Field>
  296.                       <xsl:attribute name="Name">Web</xsl:attribute>
  297.                       <xsl:attribute name="Value">
  298.                         <xsl:value-of select="c:Value"/>
  299.                       </xsl:attribute>
  300.                     </Field>
  301.  
  302.                   </xsl:if>
  303.                 </xsl:for-each>
  304.  
  305.               </Fields>
  306.             </Section>
  307.  
  308.           </Sections>
  309.         </Contact>
  310.  
  311.   </xsl:template>
  312.  
  313. </xsl:stylesheet>